import { defineConfig, loadEnv } from "vite";
import vue from "@vitejs/plugin-vue";
import { resolve } from "path";

export default defineConfig(({ mode }) => {
  return {
    plugins: [vue()],
    base: "./",
    server: {
      open: false,
      port: 8080,
      host: "0.0.0.0",
    },
    build: {
      outDir: "dist",
      sourcemap: false, //是否生成source map文件。默认值为false
      terserOptions: {
        compress: {
          drop_console: false, //生产环境移除console
          drop_debugger: false, //生产环境移除debugger
        },
      },
    },
    resolve: {
      alias: {
        "@": resolve(__dirname, "src"),
      },
    },
    define: {
      "process.env": loadEnv(mode, process.cwd()),
    },
  };
});
